<template>
  <div class="shops-detail">
    <!-- <div class="path">
      <span>资产管理</span> / {{ $route.query.ownershipName }}/
      {{ propertyinfoStorage && propertyinfoStorage.propertyName }}
    </div> -->
    <div class="shops-detail-content">
      <div class="content-name" @click="backClick">
        <i class="el-icon-arrow-left"></i>
        <div class="name">
          <span class="line"></span>
          <span>{{ $route.query.leaseUserName }}</span
          >-租赁评估信息历史记录
        </div>
      </div>
      <div class="content-info-bottom">
        <div
          class="lease-info"
          v-for="(item, index) in historyList"
          :key="index"
        >
          <div class="info-bottom-content-tips">
            <div class="info-bottom-content-time">
              签订日期：{{ item.leaseContractBeginDate }}
            </div>
            <div class="info-bottom-content-opt">
              <div class="opt">
                <el-popconfirm
                  title="是否删除当前历史租赁评估信息？"
                  @confirm="delLeaseClick(item)"
                  @onConfirm="delLeaseClick(item)"
                >
                  <el-button
                    slot="reference"
                    type="text"
                    size="small"
                    class="delete"
                    icon="el-icon-delete"
                    >删除</el-button
                  >
                </el-popconfirm>
              </div>
            </div>
          </div>
          <div class="info-bottom-content">
            <div class="info-bottom-content-left">
              <div class="title">
                <div class="info-title">租赁资产</div>
                <div class="area">
                  总租赁面积：<span v-if="item.leaseArea"
                    >{{ item.leaseArea }}㎡</span
                  ><span v-else>0㎡</span>
                </div>
                <div class="line"></div>
              </div>

              <div class="leased-assets">
                <div
                  class="leased-assets-item"
                  v-for="(v, index) in item.leasePropertyList"
                  :key="index"
                >
                  <div class="assets-img">
                    <img
                      src="../../assets/images/operating-assets.png"
                      v-if="v.businessNature === 1"
                    />

                    <img
                      src="../../assets/images/non-operating-assets.png"
                      v-else-if="v.businessNature === 0"
                    />
                  </div>
                  <div class="leased-assets-item-title">
                    <p>{{ v.ownershipName }}</p>
                    <p>权属</p>
                  </div>
                  <div class="leased-assets-item-content">
                    <el-row style="padding-bottom: 15px">
                      <el-col :span="12"
                        >资产地块：<span>{{ v.propertyName }}</span></el-col
                      >
                      <el-col :span="12"
                        >所属社区：<span>{{
                          v.propertyCommunityName
                        }}</span></el-col
                      >
                    </el-row>
                    <el-row>
                      <el-col :span="8"
                        >资产类型：<span>{{ v.propertyTypeName }}</span></el-col
                      >
                      <el-col :span="8"
                        >门牌号：<span>{{ v.doorCode }}</span></el-col
                      >
                      <el-col :span="8"
                        >租赁面积：<span>{{ v.leaseAreaTotal }}㎡</span></el-col
                      >
                    </el-row>
                  </div>
                </div>
              </div>
              <div class="jy-lease-info">
                <div class="title">
                  <div class="info-title">租赁信息</div>
                  <div class="line"></div>
                </div>
                <div class="info">
                  <div class="info-left">
                    <div class="info-left-item">
                      租赁性质：<span v-if="item.leaseNature === 1"
                        >经营性租赁</span
                      >
                      <span v-if="item.leaseNature === 0">非经营性租赁</span>
                    </div>
                    <div class="info-left-item">
                      租赁合同签订日期：{{ item.leaseContractBeginDate }}
                    </div>

                    <div class="info-left-item">
                      租赁合同终止日期：{{ item.leaseContractEndDate }}
                    </div>

                    <div class="info-left-item">
                      租赁协议：
                      <template
                        v-if="
                          item.leaseContractAttachList &&
                          item.leaseContractAttachList.length > 0
                        "
                      >
                        <span
                          style="
                            font-weight: 400;
                            color: #0052d9;
                            text-decoration: underline;
                            cursor: pointer;
                          "
                          @click="downloadClick(v.attUrl)"
                          v-for="(v, i) in item.leaseContractAttachList"
                          :key="i"
                          >{{ v.originalAttName }}</span
                        >
                      </template>
                    </div>

                    <div class="info-left-item">租赁用途：公益机构</div>

                    <div class="info-left-item">
                      租赁说明：<span style="font-weight: 400">{{
                        item.leaseInstruction
                      }}</span>
                    </div>
                  </div>
                  <div class="info-middle">
                    <div class="info-middle-table">
                      <p>租金缴纳：</p>
                      <el-table
                        :data="item.leaseRentList"
                        border
                        style="width: 100%"
                      >
                        <el-table-column label="序号" width="55" align="center">
                          <template slot-scope="scope">{{
                            (leaseForm.pageNum - 1) * leaseForm.pageSize +
                            scope.$index +
                            1
                          }}</template>
                        </el-table-column>
                        <el-table-column
                          prop="rentAmount"
                          label="租金（万元/每年）"
                          align="center"
                        >
                        </el-table-column>
                        <el-table-column
                          prop="rentFloating"
                          label="上浮（%） "
                          align="center"
                        >
                        </el-table-column>
                        <el-table-column
                          prop="payRentDate"
                          label="租金到期日期"
                          align="center"
                        >
                        </el-table-column>
                        <el-table-column label="缴租情况" align="center">
                          <template slot-scope="scope">
                            <span v-if="scope.row.rentPayFlag === 1">是</span>
                            <span v-else-if="scope.row.rentPayFlag === 0"
                              >否</span
                            >
                          </template>
                        </el-table-column>
                        <el-table-column
                          prop="rentPayDate"
                          label="缴租日期"
                          align="center"
                        >
                        </el-table-column>
                        <el-table-column
                          prop="w6"
                          label="实缴租金（万元）"
                          align="center"
                        >
                        </el-table-column>
                      </el-table>
                    </div>
                  </div>
                  <div class="info-right">
                    <div class="info-left-item" style="margin-bottom: 25px">
                      <div class="info-left-table">
                        <p>押金情况：</p>
                        <el-table
                          :data="item.leaseDepositList"
                          border
                          style="width: 60%; margin-top: 10px"
                        >
                          <el-table-column
                            label="序号"
                            width="55"
                            align="center"
                          >
                            <template slot-scope="scope">{{
                              (leaseForm.pageNum - 1) * leaseForm.pageSize +
                              scope.$index +
                              1
                            }}</template>
                          </el-table-column>
                          <el-table-column
                            prop="payDepositDate"
                            label="押金缴纳日期"
                            align="center"
                          >
                          </el-table-column>
                          <el-table-column
                            prop="depositAmount"
                            label="押金（万元）"
                            align="center"
                          >
                          </el-table-column>
                        </el-table>
                      </div>
                    </div>
                    <div class="info-left-item" style="margin-bottom: 25px">
                      租赁说明：
                    </div>
                    <div class="info-left-item">
                      其他附件：
                      <template
                        v-if="
                          item.otherAttachList &&
                          item.otherAttachList.length > 0
                        "
                      >
                        <span
                          style="
                            font-weight: 400;
                            color: #0052d9;
                            text-decoration: underline;
                            cursor: pointer;
                          "
                          @click="downloadClick(v.attUrl)"
                          v-for="(v, i) in item.otherAttachList"
                          :key="i"
                          >{{ v.originalAttName }}</span
                        >
                      </template>
                    </div>
                  </div>
                </div>
              </div>

              <div class="jy-assessment-info">
                <div class="title">
                  <div class="info-title">评估信息</div>
                  <div class="line"></div>
                </div>
                <div class="info">
                  <div class="info-left">
                    <el-row>
                      <el-col :span="8">
                        <div class="info-left-item">
                          评估报告日期：{{ item.assessReportDate }}
                        </div>
                      </el-col>
                      <el-col :span="8">
                        <div class="info-left-item">
                          评估价值时点：{{ item.assessValueDate }}
                        </div>
                      </el-col>
                      <el-col :span="8">
                        <div class="info-left-item">
                          评估价值金额：<span v-if="item.assessValueAmount"
                            >{{ item.assessValueAmount }}元/每月</span
                          >
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="24">
                        <div class="info-left-item">
                          评估报告：
                          <template
                            v-if="
                              item.assessReportAttachList &&
                              item.assessReportAttachList.length > 0
                            "
                          >
                            <span
                              style="
                                font-weight: 400;
                                color: #0052d9;
                                text-decoration: underline;
                                cursor: pointer;
                              "
                              @click="downloadClick(v.attUrl)"
                              v-for="(v, i) in item.assessReportAttachList"
                              :key="i"
                              >{{ v.originalAttName }}</span
                            >
                          </template>
                        </div>
                      </el-col>
                    </el-row>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getLeaseHistory, delLeaseInfo } from "@/api/tenant";
export default {
  components: {},
  data() {
    return {
      form: {},
      leaseForm: {
        pageNum: 1,
        pageSize: 10,
      },
      propertyinfoStorage: null,
      leaseEvaluationList: [
        {
          leaseNature: 1,
          leaseName: "小张",
          lesseeContact: "18068010914",
        },
        {
          leaseNature: 1,
          leaseName: "小张",
          lesseeContact: "18068010914",
        },
      ], // 租赁评估List
      historyList: [],
      leaseUpdateDialogVisible: false,
    };
  },
  mounted() {
    this.getLeaseHistoryInfo();
  },
  methods: {
    /**下载文件（权证） */
    downloadClick(url) {
      const a = document.createElement("a"); // 创建一个HTML 元素
      a.setAttribute("download", ""); //download属性
      a.setAttribute("href", url); // href链接
      a.setAttribute("target", "_blank");
      a.click(); // 自执行点击事件
    },
    backClick() {
      history.go(-1);
    },

    // 历史记录
    getLeaseHistoryInfo() {
      getLeaseHistory(this.$route.query.leaseUserId).then((res) => {
        if (res.code == 200) {
          this.historyList = res.data;
        }
      });
    },

    // 删除租赁评估信息
    delLeaseClick(row) {
      delLeaseInfo(row.leaseId)
        .then((res) => {
          this.$message.success("删除成功");
          this.getLeaseHistoryInfo();
        })
        .catch(() => {
          this.$message.error("删除失败");
        });
    },
  },
};
</script>

<style lang="scss" scoped>
@import "~@/styles/mixin.scss";

.shops-detail {
  .path {
    height: 40px;
    line-height: 40px;
    width: 100%;
    background: rgba($color: #fff, $alpha: 0.2);
    box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
    border-radius: 0px 0px 0px 0px;
    padding-left: 12px;
    span {
      font-weight: 600;
    }
  }
  .shops-detail-content {
    width: 98.5%;
    height: calc(100vh - 90px);
    margin: 15px auto 0;
    background: #ffffff;
    box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
    border-radius: 6px 6px 6px 6px;
    overflow-y: auto;
    .content-name {
      width: 98%;
      height: 60px;
      line-height: 60px;
      margin: 10px auto 17px;
      display: flex;
      align-items: center;
      .el-icon-arrow-left {
        width: 86px;
        height: 60px;
        line-height: 60px;
        text-align: center;
        border-right: 1px solid #e7e7e7;
        font-size: 36px;
        cursor: pointer;
      }
      .name {
        font-size: 28px;
        height: 30px;
        line-height: 30px;
        border-left: 4px solid #0052d9;
        margin-left: 16px;
        padding-left: 16px;
        position: relative;
        .line {
          border-left: 4px solid #ffc522;
          height: 12px;
          position: absolute;
          left: -4px;
          top: 0;
        }
      }
    }
    .content-info-bottom {
      width: 95%;
      margin: 0 auto 15px;
      .lease-info {
        box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
        border-radius: 8px 8px 8px 8px;
      }
      .info-bottom-content-tips {
        width: 100%;
        height: 48px;
        background: #d4e5ff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #0052d9;
        border-radius: 8px 8px 0 0;
        .info-bottom-content-time {
          font-size: 24px;
          padding-left: 35px;
        }
        .info-bottom-content-opt {
          display: flex;
          padding-right: 15px;
        }
      }
    }

    .title {
      display: flex;
      align-items: center;
      padding-left: 24px;
      color: #000;
      font-size: 18px;
      img {
        height: 30px;
        width: 30px;
      }
    }
  }
  .opt {
    padding-left: 26px;
    color: #0052d9;
    cursor: pointer;
    span {
      font-size: 12px;
      padding-left: 3px;
    }
  }
  .info-bottom-content {
    height: auto;
    background: #fafafa;
    border-radius: 0 0 8px 8px;
    // border: 1px solid #dcdcdc;
    display: flex;
    position: relative;
    margin-bottom: 16px;
    .title {
      display: flex;
      align-items: center;
      .info-title {
        border-left: 4px solid #0052d9;
        margin-top: 20px;
        padding-left: 5px;
        padding-right: 5px;
      }
      .area {
        font-size: 14px;
        color: #88909b;
        margin-top: 15px;
        padding: 0 10px;
      }
      .line {
        flex: 1;
        border: 1px solid #f3f2f2;
        margin-top: 15px;
      }
    }

    .leased-assets {
      display: flex;
      flex-wrap: wrap;
      margin-left: 1%;
      margin-top: 15px;
      .leased-assets-item {
        width: 22%;
        height: 125px;
        background: #ffffff;
        box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.1);
        border-radius: 8px 8px 8px 8px;
        margin-right: 3%;
        margin-bottom: 15px;
        position: relative;
        .assets-img {
          width: 80px;
          height: 63px;
          position: absolute;
          top: 0;
          right: 0;
          img {
            width: 100%;
          }
        }
        .leased-assets-item-title {
          display: flex;
          padding-left: 5px;
          p {
            &:nth-child(1) {
              font-size: 18px;
              color: #505a69;
            }
            &:nth-child(2) {
              width: 40px;
              height: 19px;
              text-align: center;
              line-height: 19px;
              font-size: 12px;
              color: #0064c8;
              background: #e5f2ff;
              border-radius: 4px 4px 4px 4px;
              border: 1px solid #0064c8;
              margin-top: 18px;
              margin-left: 15px;
            }
          }
        }
        .leased-assets-item-content {
          font-size: 12px;
          color: #505a69;
          padding: 5px;
          span {
            color: #000;
            font-weight: 600;
          }
        }
      }
    }
    .info-bottom-content-left {
      width: 100%;
    }
    .jy-lease-info {
      .info {
        padding-bottom: 25px;
        display: flex;
        justify-content: space-between;
        .info-left-item {
          padding-bottom: 15px;
        }
        .info-left {
          width: 20%;
          margin-left: 29px;
          margin-top: 32px;
          margin-right: 15px;
        }
        .info-middle {
          width: 40%;
          margin-top: 18px;
          .info-middle-table {
            display: flex;
          }
          .update-btn {
            float: right;
            margin-top: 10px;
          }
        }
        .info-right {
          width: 30%;
          margin-left: 29px;
          margin-top: 8px;
          margin-right: 15px;
          .info-left-table {
            display: flex;
          }
        }
      }
    }
    .jy-assessment-info {
      .info {
        padding-bottom: 25px;
        .info-left {
          margin-left: 29px;
          margin-top: 32px;
          margin-right: 15px;
          .info-left-item {
            padding-bottom: 25px;
          }
        }
      }
    }
  }
}
</style>
<style lang="scss">
.shops-detail {
  .el-table td {
    padding: 5px 0;
  }
  .el-drawer.btt {
    overflow-y: auto;
  }
  .el-button--text {
    color: #0052d9;
  }

  .el-dialog {
    border-radius: 4px;
    .el-dialog__header {
      text-align: left !important;
    }
  }
  .el-table--border::after {
    background-color: transparent;
  }
}
</style>
